import {_decorator, Component, Node, Label} from 'cc';
import {RoleInfo} from "db://assets/scripts/obj/RoleInfo";

const {ccclass, property} = _decorator;

@ccclass('RoleInfoPrefUI')
export class RoleInfoPrefUI extends Component {

    @property(Node)
    RoleName: Node = null;

    private _roleInfo: RoleInfo = null;

    get roleInfo(): RoleInfo {
        return this._roleInfo;
    }

    set roleInfo(value: RoleInfo) {
        this._roleInfo = value;
        if (value) {
            this.RoleName.getComponent(Label).string = this._roleInfo.name;
        } else {
            this.RoleName.getComponent(Label).string = "新角色";
        }
    }

    onClick() {
        if (this._roleInfo != null) {
            console.log("选角登录, roleId = ", this._roleInfo.roleId);

        } else {
            console.log("创建角色.");
        }
    }
}


